home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / python2.6 / distutils / mwerkscompiler.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-11-11  |  8KB  |  189 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''distutils.mwerkscompiler
  5.  
  6. Contains MWerksCompiler, an implementation of the abstract CCompiler class
  7. for MetroWerks CodeWarrior on the Macintosh. Needs work to support CW on
  8. Windows.'''
  9. __revision__ = '$Id: mwerkscompiler.py 55881 2007-06-11 05:28:45Z neal.norwitz $'
  10. import sys
  11. import os
  12. import string
  13. from types import *
  14. from distutils.errors import DistutilsExecError, DistutilsPlatformError, CompileError, LibError, LinkError
  15. from distutils.ccompiler import CCompiler, gen_preprocess_options, gen_lib_options
  16. import distutils.util as distutils
  17. import distutils.dir_util as distutils
  18. from distutils import log
  19.  
  20. class MWerksCompiler(CCompiler):
  21.     '''Concrete class that implements an interface to MetroWerks CodeWarrior,
  22.        as defined by the CCompiler abstract class.'''
  23.     compiler_type = 'mwerks'
  24.     executables = { }
  25.     _c_extensions = [
  26.         '.c']
  27.     _cpp_extensions = [
  28.         '.cc',
  29.         '.cpp',
  30.         '.cxx']
  31.     _rc_extensions = [
  32.         '.r']
  33.     _exp_extension = '.exp'
  34.     src_extensions = _c_extensions + _cpp_extensions + _rc_extensions
  35.     res_extension = '.rsrc'
  36.     obj_extension = '.obj'
  37.     static_lib_extension = '.lib'
  38.     shared_lib_extension = '.slb'
  39.     static_lib_format = shared_lib_format = '%s%s'
  40.     exe_extension = ''
  41.     
  42.     def __init__(self, verbose = 0, dry_run = 0, force = 0):
  43.         CCompiler.__init__(self, verbose, dry_run, force)
  44.  
  45.     
  46.     def compile(self, sources, output_dir = None, macros = None, include_dirs = None, debug = 0, extra_preargs = None, extra_postargs = None, depends = None):
  47.         (output_dir, macros, include_dirs) = self._fix_compile_args(output_dir, macros, include_dirs)
  48.         self._MWerksCompiler__sources = sources
  49.         self._MWerksCompiler__macros = macros
  50.         self._MWerksCompiler__include_dirs = include_dirs
  51.         return []
  52.  
  53.     
  54.     def link(self, target_desc, objects, output_filename, output_dir = None, libraries = None, library_dirs = None, runtime_library_dirs = None, export_symbols = None, debug = 0, extra_preargs = None, extra_postargs = None, build_temp = None, target_lang = None):
  55.         (objects, output_dir) = self._fix_object_args(objects, output_dir)
  56.         (libraries, library_dirs, runtime_library_dirs) = self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
  57.         if target_desc not in (self.SHARED_LIBRARY, self.SHARED_OBJECT):
  58.             raise DistutilsPlatformError, 'Can only make SHARED_LIBRARY or SHARED_OBJECT targets on the Mac'
  59.         target_desc not in (self.SHARED_LIBRARY, self.SHARED_OBJECT)
  60.         if runtime_library_dirs:
  61.             raise DistutilsPlatformError, 'Runtime library dirs not implemented yet'
  62.         runtime_library_dirs
  63.         if extra_preargs or extra_postargs:
  64.             raise DistutilsPlatformError, 'Runtime library dirs not implemented yet'
  65.         extra_postargs
  66.         if len(export_symbols) != 1:
  67.             raise DistutilsPlatformError, 'Need exactly one export symbol'
  68.         len(export_symbols) != 1
  69.         sources = map(self._filename_to_abs, self._MWerksCompiler__sources)
  70.         include_dirs = map(self._filename_to_abs, self._MWerksCompiler__include_dirs)
  71.         if objects:
  72.             objects = map(self._filename_to_abs, objects)
  73.         else:
  74.             objects = []
  75.         if build_temp:
  76.             build_temp = self._filename_to_abs(build_temp)
  77.         else:
  78.             build_temp = os.curdir()
  79.         if output_dir:
  80.             output_filename = os.path.join(output_dir, output_filename)
  81.         
  82.         output_filename = self._filename_to_abs(output_filename)
  83.         (output_dir, output_filename) = os.path.split(output_filename)
  84.         if output_filename[-8:] == '.ppc.slb':
  85.             basename = output_filename[:-8]
  86.         elif output_filename[-11:] == '.carbon.slb':
  87.             basename = output_filename[:-11]
  88.         else:
  89.             basename = os.path.strip(output_filename)[0]
  90.         projectname = basename + '.mcp'
  91.         targetname = basename
  92.         xmlname = basename + '.xml'
  93.         exportname = basename + '.mcp.exp'
  94.         prefixname = 'mwerks_%s_config.h' % basename
  95.         distutils.dir_util.mkpath(build_temp, dry_run = self.dry_run)
  96.         distutils.dir_util.mkpath(output_dir, dry_run = self.dry_run)
  97.         settings = { }
  98.         settings['mac_exportname'] = exportname
  99.         settings['mac_outputdir'] = output_dir
  100.         settings['mac_dllname'] = output_filename
  101.         settings['mac_targetname'] = targetname
  102.         settings['sysprefix'] = sys.prefix
  103.         settings['mac_sysprefixtype'] = 'Absolute'
  104.         sourcefilenames = []
  105.         sourcefiledirs = []
  106.         for filename in sources + objects:
  107.             (dirname, filename) = os.path.split(filename)
  108.             sourcefilenames.append(filename)
  109.             if dirname not in sourcefiledirs:
  110.                 sourcefiledirs.append(dirname)
  111.                 continue
  112.         
  113.         settings['sources'] = sourcefilenames
  114.         settings['libraries'] = libraries
  115.         settings['extrasearchdirs'] = sourcefiledirs + include_dirs + library_dirs
  116.         if self.dry_run:
  117.             print 'CALLING LINKER IN', os.getcwd()
  118.             for key, value in settings.items():
  119.                 print '%20.20s %s' % (key, value)
  120.             
  121.             return None
  122.         exportfilename = os.path.join(build_temp, exportname)
  123.         log.debug('\tCreate export file %s', exportfilename)
  124.         fp = open(exportfilename, 'w')
  125.         fp.write('%s\n' % export_symbols[0])
  126.         fp.close()
  127.         xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname))
  128.         log.debug('\tCreate XML file %s', xmlfilename)
  129.         import mkcwproject as mkcwproject
  130.         xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings)
  131.         xmlbuilder.generate()
  132.         xmldata = settings['tmp_projectxmldata']
  133.         fp = open(xmlfilename, 'w')
  134.         fp.write(xmldata)
  135.         fp.close()
  136.         projectfilename = os.path.join(os.getcwd(), os.path.join(build_temp, projectname))
  137.         log.debug('\tCreate project file %s', projectfilename)
  138.         mkcwproject.makeproject(xmlfilename, projectfilename)
  139.         log.debug('\tBuild project')
  140.         mkcwproject.buildproject(projectfilename)
  141.  
  142.     
  143.     def _filename_to_abs(self, filename):
  144.         filename = distutils.util.convert_path(filename)
  145.         if not os.path.isabs(filename):
  146.             curdir = os.getcwd()
  147.             filename = os.path.join(curdir, filename)
  148.         
  149.         components = string.split(filename, ':')
  150.         for i in range(1, len(components)):
  151.             if components[i] == '..':
  152.                 components[i] = ''
  153.                 continue
  154.         
  155.         return string.join(components, ':')
  156.  
  157.     
  158.     def library_dir_option(self, dir):
  159.         """Return the compiler option to add 'dir' to the list of
  160.         directories searched for libraries.
  161.         """
  162.         pass
  163.  
  164.     
  165.     def runtime_library_dir_option(self, dir):
  166.         """Return the compiler option to add 'dir' to the list of
  167.         directories searched for runtime libraries.
  168.         """
  169.         pass
  170.  
  171.     
  172.     def library_option(self, lib):
  173.         """Return the compiler option to add 'dir' to the list of libraries
  174.         linked into the shared library or executable.
  175.         """
  176.         pass
  177.  
  178.     
  179.     def find_library_file(self, dirs, lib, debug = 0):
  180.         """Search the specified list of directories for a static or shared
  181.         library file 'lib' and return the full path to that file.  If
  182.         'debug' true, look for a debugging version (if that makes sense on
  183.         the current platform).  Return None if 'lib' wasn't found in any of
  184.         the specified directories.
  185.         """
  186.         return 0
  187.  
  188.  
  189.